package com.xxxx.server.controller;


import com.xxxx.server.pojo.RespBean;
import com.xxxx.server.pojo.Visualdata;
import com.xxxx.server.service.IVisualdataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author LT
 * @since 2022-03-24
 */
@Api(value="数据可视化",tags = "数据可视化")
@RestController
@RequestMapping("/system/visualdata")
public class VisualdataController {

    @Autowired
    private IVisualdataService visualdataService;

    @ApiOperation(value = "获取7天内的用户数量")
    @GetMapping("/usersData7")
    public List<Visualdata> getUsers()
    {
        LocalDate today= LocalDate.now();
        return visualdataService.getUsers(today);
    }
    @ApiOperation(value = "获取7天内的讲座数量")
    @GetMapping("/lecturesData7")
    public List<Visualdata> getLectures()
    {
        LocalDate today= LocalDate.now();
        return visualdataService.getLectures(today);
    }
    @ApiOperation(value = "获取7天内的讲座预定数量")
    @GetMapping("/reverseData7")
    public List<Visualdata> getReverses()
    {
        LocalDate today= LocalDate.now();
        return visualdataService.getReverses(today);
    }
    @ApiOperation(value = "获取今天用户数量")
    @GetMapping("/usersData1")
    public Integer getTodayUsers()
    {

        return visualdataService.getTodayUsers();
    }
    @ApiOperation(value = "获取今日讲座数量")
    @GetMapping("/lecturesData1")
    public Integer getTodayLectures()
    {
         return visualdataService.getTodayLectures();
    }
    @ApiOperation(value = "获取今日讲座预定数量")
    @GetMapping("/reverseData1")
    public Integer getTodayReverses()
    {
         return visualdataService.getTodayReverses();
    }
    @ApiOperation(value = "插入可视化数据")
    @GetMapping("/InsertTodayData")
    public RespBean insertData(@RequestBody Visualdata visualdata)
    {
        if(visualdataService.save(visualdata))
        {
            return RespBean.success("数据更新成功");
        }
        return RespBean.error("数据更新失败");

    }
//    @ApiOperation(value = "插入可视化数据")
//    @GetMapping("/UpdateTodayData")
//    public RespBean UpdateData(@RequestBody Visualdata visualdata)
//    {
//        if(visualdataService.update())
//        {
//            return RespBean.success("数据更新成功");
//        }
//        return RespBean.error("数据更新失败");
//
//    }






}
